package test.unit.c41.math;


import junit.framework.TestCase;

import org.c41.math.Rational;
import org.c41.math.statistics.Descriptives;
import org.c41.math.statistics.Sample;
import org.junit.Test;

public class Statistics extends TestCase {

	@Test
	public void test() {
		Sample sample = new Sample(new long[]{2,2,3,1,3,4,4,4,5});
		Descriptives descriptives = new Descriptives(sample);
		assertEquals(new Rational(4), descriptives.mode());
		assertEquals(9, descriptives.count());
		assertEquals(new Rational(1), descriptives.minimum());
		assertEquals(new Rational(5), descriptives.maximum());
		assertEquals(new Rational(3), descriptives.median());
		assertEquals(new Rational(2), descriptives.lowerQuartile());
		assertEquals(new Rational(4), descriptives.higherQuartile());
		assertEquals(new Rational(28,9), descriptives.arithmeticMean());
		assertEquals(new Rational(540,217), descriptives.harmonicMean());
		assertEquals(new Rational(4), descriptives.range());
		assertEquals(new Rational(2), descriptives.interquartile());
		assertEquals(new Rational(116,9), descriptives.devsq());
		assertEquals(new Rational(100,9), descriptives.originMoment(2));
	}

}
